package com.gxa.jjty.cjr.controller;

import com.gxa.jjty.cjr.service.ApplicationServeService;
import com.gxa.jjty.core.common.ExceptionCode;
import com.gxa.jjty.core.exception.BusinessException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @author : 宸濯
 * Date: 2021/12/02 12:23
 * Description:
 * Version: V1.0
 */
@Api(tags = "预约服务api")
@RestController
@RequestMapping("/serve")
public class ApplicationServeController {

    @Autowired
    ApplicationServeService serveService;

    @ApiOperation("根据用户id查询所有预约服务信息")
    @ApiImplicitParam(name = "id",value = "用户id")
    @GetMapping("/findAllServe")
    public Map<String,Object> findAllServe(Long id) throws BusinessException {
        if (id==null){
            throw new BusinessException(ExceptionCode.ID_NOTNULL);
        }
        return serveService.findAllServe(id);
    }

    @ApiOperation("关注服务")
    @GetMapping("/concerned")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "handicappedId",value = "用户id"),
            @ApiImplicitParam(name = "appServeId",value = "服务id")
    })
    public Map<String,Object> concerned(Long handicappedId,Long appServeId) throws BusinessException {
        if (handicappedId==null || appServeId==null){
            throw new BusinessException(ExceptionCode.ID_NOTNULL);
        }
        return serveService.concerned(handicappedId,appServeId);
    }

    @ApiOperation("取消关注")
    @GetMapping("/unconcerned")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "handicappedId",value = "用户id"),
            @ApiImplicitParam(name = "appServeId",value = "服务id")
    })
    public Map<String,Object> unconcerned(Long handicappedId,Long appServeId) throws BusinessException {
        if (handicappedId==null || appServeId==null){
            throw new BusinessException(ExceptionCode.ID_NOTNULL);
        }
        return serveService.unconcerned(handicappedId,appServeId);
    }
}
